package com.spsoft.core.config;

import com.spsoft.core.utils.StringUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.io.File;

/**
 * @author wangy
 * @date 2023/11/29 17:09
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "vms")
public class VmsCommonProperties {

    /**
     * 版式文件文件存放路径
     */
    private String filePath;

    /**
     * 发票文件存放路径
     */
    private String fullPath;

    /**
     * 系统临时文件存储路径
     */
    private String localPath;

    /**
     * web端开具发票导入原始文件存储路径
     */
    private String webImportOriginalFilePath;

    /**
     * web端开具发票版式文件存储路径
     */
    private String webImportLayoutFilePath;

    /**
     * 修补路径 补齐/
     * @return
     */
    public String filePath() {
        if (StringUtil.isNotEmpty(filePath) && !File.separator.equals(filePath.substring(filePath.length() - 1))) {
            return filePath + File.separator;
        }
        return filePath;
    }

    /**
     * 修补路径 补齐/
     * @return
     */
    public String fullPath() {
        if (StringUtil.isNotEmpty(fullPath) && !File.separator.equals(fullPath.substring(fullPath.length() - 1))) {
            return fullPath + File.separator;
        }
        return fullPath;
    }

    /**
     * 修补路径 补齐/
     * @return
     */
    public String localPath() {
        if (StringUtil.isNotEmpty(localPath) && !File.separator.equals(localPath.substring(localPath.length() - 1))) {
            return localPath + File.separator;
        }
        return localPath;
    }

    /**
     * 修补路径 补齐/
     * @return
     */
    public String webImportOriginalFilePath() {
        if (StringUtil.isNotEmpty(webImportOriginalFilePath) && !File.separator.equals(webImportOriginalFilePath.substring(webImportOriginalFilePath.length() - 1))) {
            return webImportOriginalFilePath + File.separator;
        }
        return webImportOriginalFilePath;
    }

    /**
     * 修补路径 补齐/
     * @return
     */
    public String webImportLayoutFilePath() {
        if (StringUtil.isNotEmpty(webImportLayoutFilePath) && !File.separator.equals(webImportLayoutFilePath.substring(webImportLayoutFilePath.length() - 1))) {
            return webImportLayoutFilePath + File.separator;
        }
        return webImportLayoutFilePath;
    }

}
